var mapIds = [350060160, 350060180, 350060200];
var 准备地图 = 350060000;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("黑色天堂_Act6_斯乌");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    return c
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(5);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(30 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a);
    var d = em.getNumberProperty("state");
    em.setProperty("state", d + 1)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(b, c) {
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a);
    if (c == 8240097 || c == 8240103) {
        player.getAPI().userSetFieldFloating(350060220, 20, 20, 20);
        player.getAPI().fieldEffect_PlayFieldSound("BlackHeavenBoss/CoreEnd", 100);
        player.getAPI().fieldEffect_ScreenMsg("Map/Effect2.img/blackHeavenBossDie3");
        if (player.getAPI().getNumberFromQuestInfo(33293, "difficulty") == 0) {
            player.scheduleWarpTask(6, 350060180, 0, false)
        } else {
            player.scheduleWarpTask(6, 350060240, 0, false)
        }
    } else {
        if (c == 8240098 || c == 8240104) {
            player.getAPI().userSetFieldFloating(350060180, 20, 20, 20);
            player.getAPI().fieldEffect_ScreenMsg("Map/Effect2.img/blackHeavenBossDie2");
            player.getAPI().fieldEffect_PlayFieldSound("BlackHeavenBoss/WhiteOut", 100);
            player.getAPI().userSetFieldFloating(350060180, 0, 0, 0);
            if (player.getAPI().getNumberFromQuestInfo(33293, "difficulty") == 0) {
                player.scheduleWarpTask(5, 350060200, 0, false)
            } else {
                player.scheduleWarpTask(5, 350060260, 0, false)
            }
        } else {
            if (c == 8240099 || c == 8240105) {
                player.getAPI().updateInfoQuest(33293, "");
                player.getAPI().fieldEffect_ScreenMsg("Map/Effect2.img/blackHeavenBossDie3");
                player.scheduleWarpTask(10, 350061100, 0, false)
            }
        }
    }
    return 1
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onMonsterDamaged() {}

function onItemPickedUp() {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};